package com.sumainfor.zuul.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.zuul.service.ZfeignService;
import com.sumainfor.zuul.service.ZxZuulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 由前端直接调用网关的控制器
 *
 */
@RestController
@RequestMapping("/ZxZuul")
public class ZxZuulController {

    @Autowired
    private ZxZuulService zxZuulService;
    /**
     * 租后主管分配管家时查询租后主管所在的服务中心下的所有服务管家
     */
    @GetMapping("/getButlerUserIdList")
    public JsonResult getButlerUserIdList(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=zxZuulService.getButlerUserIdList(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 根据员工编号查询角色的信息
     * @return
     */
    @GetMapping("/getUserRoleInfo")
    public JsonResult getUserRoleInfo(@RequestParam  Map<String,Object> params){
        JsonResult result=new JsonResult();

        Map<String,Object> map=zxZuulService.getUserRoleInfo(params);
        if(map!=null){
            result.put(map);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 查询所有服务中心
     * @return
     */
    @GetMapping("/getDeptListByType")
    public JsonResult getDeptListByType(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=zxZuulService.getDeptListByType(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 根据公司编号查询公司所在的市编号
     * @return
     */
    @GetMapping("/getSysArea")
    public JsonResult getSysArea(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        Map<String,Object> map=zxZuulService.getSysArea(params);
        if(map!=null){
            result.put(map);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 根据公司编号查询公司所在的市编号
     * @return
     */
    @GetMapping("/getTransferInfoList")
    public JsonResult getTransferInfoList(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
       List<Map<String,Object>> list=zxZuulService.getTransferInfoList(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 工程经理查询某个服务中心下的维修师傅
     */
    @GetMapping("/getEnUserIdList")
    public JsonResult getEnUserIdList(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=zxZuulService.getEnUserIdList(params);
        if(list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 工程经理查询某个服务中心下的维修师傅
     */
    @PostMapping("/getStaffList")
    public JsonResult getStaffList(@RequestBody Map<String,Object> params){
        return zxZuulService.getStaffList(params);
    }

}
